package com.atguigu.lease.common.exceptions;

import com.atguigu.lease.common.result.ResultCodeEnum;
import lombok.Data;

/**
 * @Author zhaolingqiao
 * @CreateTime 2024/12/11
 * 自定义公寓执行失败的异常
 */
@Data
public class LeaseException extends RuntimeException{
    private Integer code;

    public LeaseException(String message) {
        super(message);
    }

    public LeaseException(String message, Integer code) {
        super(message);
        this.code = code;
    }
    /**
     * 优化：使用枚举构造异常
     */
    public LeaseException(ResultCodeEnum resultCodeEnum){
        super(resultCodeEnum.getMessage());
        this.code=resultCodeEnum.getCode();
    }
}
